<?php

// 4/10/2010: immanuel192 write this modeler
class slide_song_verse {
	function form($object,$verse) { // input: song object
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		global $db;
		if (!isset($verse->id))
		{
			$verse->content="";
			$verse->background=-1;
			$verse->song_id=$object->id;
		}
		else
		{
			$form->meta('verse_id',$verse->id);
		}
		$form->meta('id',$object->id);
		
		$collection_default=$object->collection_id;
		$collection=$db->selectDropdown("present_song_collection","name");
		
		if (isset($object->id))
			$collection_default=$object->collection_id;
		foreach ($collection as $key=>$value) {
			if ($key == $collection_default)
			{ $object->collection_id=$key; break; }
		}
		
		$form->register("song_name","Song Name",new textcontrol($object->name,51,false,200));
		$form->register('collection_id',"Collection",new dropdowncontrol($object->collection_id,$collection));
		$form->register("song_no","Song number",new textcontrol($object->song_no));
		
		$form->register("content","Verse",new htmleditorcontrol($verse->content));
		$form->register('background','Background file', new ajax_select_file('background',0,$verse->background,true));
		
		$form->register('submit','',new buttongroupcontrol('Save','','Cancel'));
		return $form;
	}

	function update($values,$object) {
		$object->song_id = intval($values['id']);
		$object->content = $values['content'];
		$object->background = $values['background'];
		return $object;
	}
}

?>
